<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>角色权限管理页</title>
</head>
<%
	String path = request.getContextPath();
	request.setAttribute("path", request.getContextPath());
	request.setAttribute("jsPath", path+"/js");
%>
<%
	if(request.getAttribute("list") == null){
		response.sendRedirect(request.getContextPath()+"/roleAuthority/get");
	}
%>
<style type="text/css">
	table{width:100%;}
	tr{text-align:center;}
</style>
<script type="text/javascript" src="${jsPath}/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${jsPath}/global.js"></script>
<script type="text/javascript">
	$(function(){
		var msg = $("#msg").html();
		if(msg != null){
			alert(msg);
		}
	});
	
	function search(){
		$("#pageIndex").val(1);
		$('#searchForm').submit();
	}
	
	function goPage(pageIndex){
		$("#pageIndex").val(pageIndex);
		$('#searchForm').submit();
	}
	
	$(function(){
		$("#myPageIndex").blur(function(){
			var myPageIndex = parseInt($(this).val());
			var totalPage = parseInt($("#totalPage").html());
			var reg = /\d/;
			if(reg.test(myPageIndex) == false){
				$(this).val(1);
			}
			if(myPageIndex > totalPage){
				$(this).val(totalPage);
			}
		});
	});
</script>
<body>
	<c:if test="${not empty roleAuthorityVo.msg}"><p style="display:none" id="msg">${roleAuthorityVo.msg}</p></c:if>
	<form action="${path}/roleAuthority/get" method="get" id="searchForm">
		<p>角色名称(支持模糊查询)
			 <input type="text" name="roleName" value="${roleAuthorityVo.roleName}"/>
			 <input type="hidden" id="pageIndex" name="pageIndex" value="${roleAuthorityVo.pageIndex}"/> 
			<input type="button" value="查找" onclick="search()"/>
		</p>
	</form>
	<table>
		<tr>
			<th>序号</th>
			<th>角色ID</th>
			<th>角色名称</th>
			<th>权限名称</th>
			<th>创建时间</th>
			<th>操作</th>
		 </tr>
		 <c:forEach var="roleAuthority" items="${list}" varStatus="status">
		 	<tr>
		 		<%-- <td>${status.index+1+(roleAuthorityVo.pageIndex-1)*roleAuthorityVo.pageRows}</td> --%>
		 		<td>${status.index+1}</td>
			 	<td><c:out value="${roleAuthority.roleId}"></c:out></td>
				<td><c:out value="${roleAuthority.roleName}"></c:out></td>
				<td><c:out value="${roleAuthority.authorityName}"></c:out></td>
				<td><c:out value="${roleAuthority.createTime}"></c:out></td>
				<td>
					<a class="btn" href="${path}/roleAuthority/modifyPage?roleAuthorityId=${roleAuthority.roleAuthorityId}">修改</a>
					<a class="btn" href="${path}/roleAuthority/delete?roleAuthorityId=${roleAuthority.roleAuthorityId}">删除</a>
				</td>
		 	</tr>
		 </c:forEach>
	</table>
	<p>
		<c:if test="${roleAuthorityVo.pageIndex>1}"><a class="btn" href="javaScript:void(0)" onclick="goPage(${roleAuthorityVo.pageIndex-1})">上一页</a></c:if>
		<c:if test="${roleAuthorityVo.pageIndex<totalPages}"><a class="btn" href="javascript:void(0)" onclick="goPage(${roleAuthorityVo.pageIndex+1})">下一页</a></c:if>
		--第<input id="myPageIndex" type="text" size="1" value="${roleAuthorityVo.pageIndex}"/>页,
		共<span id="totalPage">${totalPages}</span>页 --
		<a class="btn" href="javaScript:void(0)" onclick="goPage($('#myPageIndex').val())">跳转</a>
	</p>
	<p><a class="btn" href="${path}/roleAuthority/addPage">权限配置</a></p>
</body>
</html>